function updateShoppingCar()
{
	// 显示购物车信息
	$.ajax({
			url: commonUtil.base + "/shop/cart_item!ajaxList.action",
			dataType: "json",
			beforeSend: function() {
			},
			success: function(data) {
				isAjaxDate = false;
				var cartItemInfoHtml = "";
				var cartItemListHtml = "";
				var totalQuantity = 0;
				
				$.each(data, function(index, object) {
					if (index == 0) {
						totalQuantity +=parseInt(object.totalQuantity);
					}
				});
				$("#shoppingcar").html(totalQuantity);
			}
		})
}
$().ready( function() {

	$('.corner').corner("round 8px top");
	$(".onlineService").floatdiv({top:"150px",right:"100px"});
	updateShoppingCar();

	// 刷新header登录、注册信息
	$.flushHeaderInfo = function () {
		var $headerShowLoginWindow = $("#headerShowLoginWindow");
		var $headerShowRegisterWindow = $("#headerShowRegisterWindow");
		var $headerLoginMemberUsername = $("#headerLoginMemberUsername");
		var $headerMemberCenter = $("#headerMemberCenter");
		var $headerLogout = $("#headerLogout");
		if($.cookie("loginMemberUsername") != null) {
			$headerLoginMemberUsername.text($.cookie("loginMemberUsername"));
			//$headerMemberCenter.show();
			$headerLogout.show();
			$headerShowLoginWindow.hide();
			$headerShowRegisterWindow.hide();
		} else {
			$headerLoginMemberUsername.text("");
			$headerShowLoginWindow.show();
			$headerShowRegisterWindow.show();
			//$headerMemberCenter.hide();
			$headerLogout.hide();
		}
	}
	
	$.flushHeaderInfo();
	
	// 商品搜索
	$productSearchKeyword = $("#productSearchKeyword");
	productSearchKeywordDefaultValue = $("#productSearchKeyword").val();
	$productSearchKeyword.focus( function() {
		if ($productSearchKeyword.val() == productSearchKeywordDefaultValue) {
			$productSearchKeyword.val("");
		}
	});
	
	$productSearchKeyword.blur( function() {
		if ($productSearchKeyword.val() == "") {
			$productSearchKeyword.val(productSearchKeywordDefaultValue);
		}
	});
	
	$("#productSearchForm").submit( function() {
		if ($.trim($productSearchKeyword.val()) == "" || $.trim($productSearchKeyword.val()) == productSearchKeywordDefaultValue) {
			return false;
		}
	});
	
	$("#cartItemListDetail").hover(
		function() {
			$("#cartItemListDetail").stop(true, true);
			$("#cartItemListDetail").show();
		},
		function() {
			$("#cartItemListDetail").fadeOut();
		}
	)
	
	
	$(".top_menu ul li.normal").hover(
		function () { 
			$(this).toggleClass("current"); },
		function() {
			$(this).toggleClass("current");
		});
	
	// 刷新购物车信息
	$.flushCartItemList = function() {
		isAjaxDate = true;
	}
	
	$(".top_menu ul li.first").hover(
	function () { 
		$(".dynamicMenu").removeClass("hidden");
		 },
	function() {
		$(".dynamicMenu").addClass("hidden");
	});
	
	$('.validationForm').each(function(i){
		$(this).validate();
	 });
	
	
	

});